import {deleteFormRequest, stopFormRequest} from '@/api/project/form'
import {logicDeleteFormRequest} from "../../../api/project/form"
import dayjs from "dayjs"

export default {
  props: [],
  data() {
    return {
      folderId: 0,
      projectStatusList: [
        {code: '', name: '全部', color: '#006EFF'},
        {code: 1, name: '未发布', color: '#006EFF'},
        {code: 2, name: '收集中', color: '#34C82A'},
        {code: 3, name: '已结束', color: '#955A45'}
      ],
      projectTypeList: [
        {code: '', name: '全部', color: '#006EFF'},
        {code: 1, name: '普通', color: '#DFAB5C'},
        {code: 2, name: '流程', color: '#5190DE'},
        {code: 4, name: '考试', color: '#59C075'}
      ]
    }
  },
  filters: {
    formatDate(time) {
      return dayjs(time).format('YYYY/MM/DD')
    }
  },
  computed: {},
  methods: {
    getType(key){
      const item = this.projectTypeList.find((e) => e.code === key)
      return item ? item : {name: '', color: ''}
    },
    logicDeleteForm(key) {
      logicDeleteFormRequest({formKey: key}).then((res) => {
        if (res.data) {
          this.msgSuccess('刪除成功')
          this.$emit('refresh')
        }
      })
    },
    deleteForm(key) {
      deleteFormRequest({formKey: key}).then((res) => {
        if (res.data) {
          this.msgSuccess('刪除成功')
          this.$emit('refresh')
        }
      })
    },
    stopProject(key) {
      stopFormRequest({formKey: key}).then((res) => {
        if (res.data) {
          this.msgSuccess('停止成功')
          this.$emit('refresh')
        }
      })
    },
    toProjectHandle(form, type,currentPage) {
      console.log(form,type,'form----')
      this.$store.dispatch('form/setBackRoute', this.$route.path)
      this.$store.dispatch('form/setCurrentPage', currentPage)
      this.$router.push({path: `/project/form/${type}`, query: {key: form.formKey, active: type,type:form.type,name:form.textName}})
    }
  }
}
